﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace PropertyManagement.Core.Model {
    public class SystemUser:AbstractBaseEntity {
        public int SystemUserID { get; set; }
        [BPrimaryKey]
        public string UserName { get; set; }
        public string Password { get; set; }
        public RightLevel RightLevel { get; set; }
        public string RightLevelName {
            get { return RightLevelHelper.GetRightLevelName(RightLevel); }
        }
      
        public string Status {
            get { return IsValid ? "可用" : "不可用"; }
        }
        public string PasswordQuestion1 { get; set; }
        public string PasswordQuestion2 { get; set; }
        public string PasswordQuestion3 { get; set; }

        public string PasswordAnswer1 { get; set; }
        public string PasswordAnswer2 { get; set; }
        public string PasswordAnswer3 { get; set; }
        public bool IsValid { get; set; }
        public static string MD5Pwd(string origionPassword) {

            var md5 = new MD5CryptoServiceProvider( );
            string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(origionPassword)), 4, 8);
            t2 = t2.Replace("-", "");
            return t2;

        }
    }
}
